package com.csj.DesignPattern.prototype.deepClone;

import java.io.Serializable;

public class Citation implements Cloneable, Serializable {

    private Student student;

    public void show() {
        System.out.println(this.student.getName() + "同学：在2020学年第一学期中表现优秀，被评为三好学生。特发此状！");
    }

    //克隆后的新对象，是通过clone方法，而不是通过构造器new
    public Citation() {
        //所以该语句只会打印一次
        System.out.println("构造器");
    }

    //浅克隆，只拷贝对象本身，不拷贝对象中的引用类型
    @Override
    protected Citation clone() throws CloneNotSupportedException {
        return (Citation) super.clone();
    }

    public void setStudent(Student student) {
        this.student = student;
    }

    public Student getStudent() {
        return student;
    }
}
